﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _5._18
{
    public partial class GoodsForm : Form
    {
        public GoodsForm()
        {
            InitializeComponent();
        }

        private void vovo()
        {
            string sql = "select * from T_GoodsInto";
            DataTable table = DBHelper.read(sql);
            this.dataGridView1.AutoGenerateColumns = false;
            this.dataGridView1.DataSource = table;
        }
        private void GoodsForm_Load(object sender, EventArgs e)
        {
            vovo();
        }

        private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int id =Convert.ToInt16(this.dataGridView1.SelectedRows[0].Cells["Goodsid"].Value);
            string sql = string.Format("delete  from T_GoodsInto where Goodsid={0}", id);
            int rs = DBHelper.write(sql);
            if (rs > 0)
            {
                MessageBox.Show("删除成功......");
                vovo();
                
            }
            else
            {

                MessageBox.Show("删除失败......");
            }
        }

        private void 修改ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt16(this.dataGridView1.SelectedRows[0].Cells["Goodsid"].Value);
            Update update = new Update(id);
            update.Show();
            
        }

        private void 添加ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Insert insert = new Insert();
            insert.Show();
        }

        private void 刷新ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            vovo();
        }
    }
}
